#include <camera/camera.h>

Camera::Camera () :
	tagMessage(),
	imageIndex(1)
{
	ROS_INFO("Starting up Camera node.");

	ros::NodeHandle nh("camera");
	ros::Rate loop_rate(5);

	snapshot_service 	= nh.advertiseService("/sensor/camera/snapshot", &Camera::takeSnapshot, this);
	tag_publisher 		= nh.advertise<sensor::tag>("/sensor/tag", 0);
	tagMessage.angle 	= 0.0;

	// Load the tag descriptors.
	loadDescriptor();

/*	if (openCapture() && false)	 	// Do we capture in this node?
	{
		while (ros::ok())
		{
			captureImage();	// Capture an image
			loop_rate.sleep();
		}
	} else 							// Or read out a stream of images? */
		joinImageTopic(nh);

	ROS_INFO("Image capture complete.");
}


/**
 * 	Camera startup code. This initializes the OpenCV window
 * 	thread used to display the captured image, and starts the
 * 	Camera node.
 */
int main (int argc, char **argv)
{
  	ros::init(argc, argv, "camera");
/*	cv::namedWindow("camera window");
	cv::namedWindow("parse window");
	cv::startWindowThread();
*/
  	new Camera();

/*	cv::destroyWindow("camera window");
	cv::destroyWindow("parse window");*/
	return 0;
}
